<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .ng-cloak{
            display:none;
        }
    </style>

</head>
<body ng-app="hd" ng-cloak class="ng-cloak" >
<div ng-controller="ctrl">
    商品名称：{{goods.data.title}}<br/>
    商品价格：{{goods.data.price}}<br/>
    商品数量：{{goods.data.num}}<br/>
    总计：{{goods.data.price*goods.data.num}}<br/>

    <button ng-click="goods.add()"> 增加</button>
    <button ng-click="goods.reduce()"> 减少</button>
</div>
<script src="../org/angular.min.js"></script>
<script>
    var m = angular.module('hd', []);
    m.controller('ctrl', ['$scope', function ($scope) {
        $scope.goods = {
            data:{'title': 'mac', 'price': 300, 'num': 0},
            add : function () {
                $scope.goods.data.num = Math.min(++$scope.goods.data.num,15);
            },
            reduce : function () {
            $scope.goods.data.num = Math.max(--$scope.goods.data.num,0);
        }
        }

    }])
</script>

</body>
</html>